<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script>
  </head>
  <body>
    <div ng-app="myApp" ng-controller="myCtrl">
      <h1>{{indexName}}</h1>
      <span>父组件:</span>
      <h2>{{childName}}</h2>
      <input type="text" ng-model="indexInput" placeholder="请输入indexInput内容">
      <!-- 自定义组件 -->
      <hello-world></hello-world>
    </div>

    <script>
      var app = angular.module("myApp", []);
      app.controller("myCtrl", function ($scope) {
        $scope.indexName = "主页";
        $scope.childName = "父组件自定义组件名称"
      });
      app.directive("helloWorld",function(){
          return {
            restrict:'ECMA',
            scope:{},
            template:`
            <div>
              <h2>{{childName}}</h2>
              <span>自定义组件:</span>
              <input type="text" ng-model="indexInput" placeholder="请输入childInput内容">
            </div>
            `,
            controller:function($scope){
            }
          }
      })
    </script>

  </body>
</html>
